package cn.acheng1314.springboot2.handler

import cn.acheng1314.springboot2.model.ResponseWrap
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.ResponseBody

import javax.servlet.http.HttpServletRequest

@ControllerAdvice
class GlobalExceptionHandler {

    @ExceptionHandler(value = [(Exception::class)])
    @Throws(Exception::class)
    @ResponseBody
    fun defaultErrorHandler(req: HttpServletRequest, e: Exception) = ResponseWrap<Exception>().warp(e)

}